﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using PPI.Entities.Kml;
using PPI.Entities.Settings;
using PPI.WebConsumer;
using VMind.Global;

namespace PPI.Client.Logic
{
    public class LCustomKml : LSettings
    {
        public static List<EKmlFile> SelectKML()
        {
            List<EKmlFile> _KmlCodes = new List<EKmlFile>();
            _KmlCodes.Add(new EKmlFile(SelectInspectionKmlSetting().SettingText));
            _KmlCodes.Add(new EKmlFile(SelectGpsKmlSetting().SettingText));
            return _KmlCodes;
        }

        public static ESettingsCustomInspectionKml SelectInspectionKmlSetting()
        {
            ESettingsCustomInspectionKml tmpInspectionKml = (ESettingsCustomInspectionKml)LCustomKml.GetSetting(new ESettingsCustomInspectionKml());
            return tmpInspectionKml;
        }

        public static ESettingsCustomGpsKml SelectGpsKmlSetting()
        {
            ESettingsCustomGpsKml tmpGpsKml = (ESettingsCustomGpsKml)LCustomKml.GetSetting(new ESettingsCustomGpsKml());
            return tmpGpsKml;
        }

        public static string ParseKml(string databaseKml)
        {
            string returnKml = databaseKml;
            int _StartingIndex = databaseKml.IndexOf("<Document>") + "<Document>".Length;
            if (databaseKml.IndexOf("<Document>") > -1)
            {
                returnKml = databaseKml.Substring(_StartingIndex, databaseKml.Length - _StartingIndex);
                _StartingIndex = returnKml.IndexOf("</Document>");
                returnKml = returnKml.Substring(0, _StartingIndex);
            }
            return returnKml;
        }


    }
}
